import { IPrefab, PrefabPath } from "../../config/PrefabPath";
import UIManager from "../managers/UIManager";
import DialogBase, { IDialogBase } from "./DialogBase";

const { ccclass, property } = cc._decorator;
/**
 * 弹窗基类
 */
@ccclass
export default class ToastBase extends DialogBase implements IDialogBase {
    skinPrefab: IPrefab = PrefabPath.toastTipLayer;
    @property({ type: cc.Label, displayName: '显示内容' })
    public lab_content: cc.Label = null;

    public async show(options?: string): Promise<void> {
        this.options = options || Object.create(null);
        this.init(this.options);
        this.updateDisplay(this.options);
        cc.Tween.stopAllByTarget(this.main);
        cc.tween(this.main)
            .set({ opacity: 0, y: 0 })
            .by(0.5, { opacity: 255, y: 240 })
            .delay(0.5)
            .by(0.5, { opacity: -255, y: 230 })
            .call(() => {
                UIManager.hide(this.skinPrefab)
            })
            .start();
    }

    public async hide() {

    }
    updateDisplay(text: string): void {
        this.lab_content.string = text;
    }
}
